package edu.whut.regexTest;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexPattern {
    public static void main(String[] args) {
        String data = "来黑马程序员学Java，电话18736290143，邮箱2970489332@qq.com，热线400-618-9000，4006189584，座机010-98554477";
        String regex = "[1][3-9]\\d{9}|\\w+[@][\\w&&[^_]]+(\\.[a-z]{2,3})+|[0]\\d{2,3}-?\\d{7,8}|400-?\\d{7,8}|400-?\\d{3}-?\\d{4}";

        //将正则表达式封装为Pattern对象
        Pattern pattern = Pattern.compile(regex);

        //获取匹配器对象
        Matcher matcher = pattern.matcher(data);

//        //find要和group配合使用,find像指针一样
//        System.out.println(matcher.find());
//        System.out.println(matcher.group());
//
        while(matcher.find()){
            System.out.println(matcher.group());
        }
    }
}
